<?php
/**
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       Cake.View.Layouts
 * @since         CakePHP(tm) v 0.10.0.1076
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

//$cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework');
$rhDescription="Биллинг Radioheart.ru";
$current_controller=$this->params['controller'];
$current_action=$this->params['action'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php echo $this->Html->charset(); ?>
	<title>
		<?php echo $rhDescription ?>:
		<?php echo $title_for_layout; ?>
	</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
        <link href='http://fonts.googleapis.com/css?family=PT+Sans&subset=latin,cyrillic' rel='stylesheet' type='text/css'>	<?php
		echo $this->Html->meta('icon');

		//echo $this->Html->css('cake.generic');
		echo $this->Html->css('../style');

		echo $this->fetch('meta');
		echo $this->fetch('css');
		echo $this->fetch('script');
		//echo $this->Html->script('jquery-1.6.4.min');
		echo $this->Html->script('pGenerator.jquery');
		echo $this->Html->script('encr');
		echo $this->Html->script('jquery.md5');
		echo $this->Html->script('jquery.cookie');
		echo $this->Html->script('jquery.placeholder.min');
		echo $this->Html->css('../style_steps');
                echo $this->Html->css('../style_step2');
	?>
        <script type="text/javascript">
            function logo_heartbit()
            {
                $(".logo").animate({ opacity: 0.4 },2000).animate({ opacity: 1 },2000);
            }
            $(document).ready(function(){
		var screen_height=$(window).height();

		$(".billing_not_logged_wrp").css('height',screen_height);
		var div=$('#billing_login_wrapper');
		div.css("top", ($(window).height() - div.height())/2  + 'px');
		$("#reload").click(function(){
			$('#captcha').attr('src', $('#captcha').attr('src') + '?' + new Date().getTime())
		    });
                /*
                logo_heartbit();
                var beats=setInterval('logo_heartbit()',4000);
                $(".logo").hover(function(){
                    $(".logo").animate({ opacity: 1 },1000);
                    clearInterval(beats);
                },function(){
                    logo_heartbit();
                    var beats=setInterval('logo_heartbit()',4000); }); */
                $(".billing_order_select_line").click(function(){
                  var id=event.target.id;
                  billing_orders_select_line_delete_class(id);
                  $("#"+id).addClass("billing_order_select_line_current");
                  billing_orders_select_line_hide_all_divs();
                  $("#div_"+id).show();
                });
		$(".billing_sidebar_userinfo").click(function(){
			window.location.href = "<?php echo $this->Html->url(array('controller'=>'users','action'=>'addcredits')); ?>";
		});
            });
            function billing_orders_select_line_delete_class(id)
            {
              $(".billing_order_select_line_current").each(function(index){
                $(this).removeClass("billing_order_select_line_current");
              });
            }
            function billing_orders_select_line_hide_all_divs(){
              $(".billing_order_super_shower").each(function(index){
                $(this).hide();
              });
            }
            function expand(div_numder){
	      rollaup_all();
              $("#order_small_"+div_numder).hide();
              $("#order_full_"+div_numder).show();
	      //при отркытии большого, сначала скрываем все внутренние, потом показываем информацию
	      //billing_orders_select_line_hide_all_divs();
	      var id="order_super_info_link_"+div_numder;
	      $("#"+id).addClass("billing_order_select_line_current");
	      $("#div_"+id).show();
            }
            function rollup(div_numder){
              $("#order_full_"+div_numder).hide();
              $("#order_small_"+div_numder).show();
            }
	    function rollaup_all() {
		$(".billing_orders_full_wrp").each(function(index){
                if($(this).is(":visible"))
		{
			var id=$(this).attr('id');
			id=id.replace("full", "small");
			$(this).hide();
			$("#"+id).show();
		}
              });
	    }
        </script>
        <script>
          $(function() {
            $( ".billing_order_super_extend_slider" ).each(function(index){

              $(this).slider({
                range: "max",
                min: 1,
                max: 12,
                value: 1,
                step:1,
                slide: function( event, ui ) {
                  var id=$(this).attr('id');
                  var data="";
                  var discount=1;
                  switch(ui.value)
                  {
                    case 1: data="1 месяц"; break;
                    case 2: data="2 месяца"; break;
                    case 3: data="3 месяца";discount=0.95; break;
                    case 4: data="4 месяца";discount=0.95; break;
                    case 5: data="5 месяцев";discount=0.95; break;
                    case 6: data="6 месяцев";discount=0.9; break;
                    case 7: data="7 месяцев";discount=0.9; break;
                    case 8: data="8 месяцев";discount=0.9; break;
                    case 9: data="9 месяцев";discount=0.9; break;
                    case 10: data="10 месяцев";discount=0.9; break;
                    case 11: data="11 месяцев";discount=0.9; break;
                    case 12: data="12 месяцев";discount=0.85; break;

                  }
                  $("#monthes_div_"+id).html(data);
                  //var month_cost=$("#result_cost_"+id).html();
                  var month_cost=$("#result_cost_"+id).attr('value')*discount;
		  month_cost=month_cost.toFixed(2);
                  var total_cost=month_cost*ui.value;
                  $("#span_cost_"+id).html(total_cost.toFixed(2)+" $");
                  $("#span_monthes_"+id).html("за "+data);
		  $("#monthes_input_"+id).val(ui.value);
                  var balance_value=$("#billing_sidebar_balance_value").attr('value');
                  var notice="";
                  if(balance_value<total_cost)
                  {
                    $("#pay_button_"+id).addClass("billing_orders_pay_button_disabled");
                    $("#pay_button_"+id).click(function () {return false;});
                    var not_enought=total_cost-balance_value;
		    not_enought=not_enought.toFixed(2);
                    notice="Для продления заказа на указанное количество месяцев<br /> недостаточно "+not_enought+" $ на балансе. <br /><a href='#'>Пополнить баланс</a><br /><a href='#'>Пополнить баланс на "+not_enought+" $</a>";
                  }
                  else
                  {
                    $("#pay_button_"+id).removeClass("billing_orders_pay_button_disabled");
                    $("#pay_button_"+id).unbind('click');
                    notice="Средства будут списаны с вашего баланса"
                  }
                  $("#div_notice_"+id).html(notice);
                  //$.cookie('bitrate', ui.value, { expires: 1 });
                  //calculate();
                }
              });
            });
          });
        </script>
	<script type="text/javascript">
                      function closeOnLoad(myLink)
                      {
                        var newWindow = window.open(myLink);
                        setTimeout(function(){newWindow.close();alert("Диджей успешно кикнут!");},1000);
                      }
                function icecast(action,serverip,port,orderid)
                {
                  $.ajax({
                                 type: "GET",
                                 url: "modules/billing/icecast.php",  //Тут указываем файл со скриптами
                                 cache: false,
                                 data: "serverip="+serverip+"&port="+port+"&action="+action,
                                 success: function(res){
                                   //alert(res);
                                   if(strpos(res,"illedKilled")>0)
                                    alert("Сервер отключен");
                                   else
                                     if(strpos(res, "hanged groupid to")>0)
                                      alert("Сервер включен");
                                     else
                                        alert("Что-то не так, сервер не запущен/не отключен");
                                   icecaststatus(serverip,port,orderid);
                                 }
                  });
                }
                function strpos (haystack, needle, offset) {
                  var i = (haystack + "").indexOf(needle, (offset || 0));
                  return i === -1 ? false : i;
                }
        </script>
	    <script>
        $(document).ready(function(){
          $('.passgenlnk').pGenerator({
              'bind': 'click',
              'passwordElement': '#OrderApassword',
              'displayElement': '#OrderApassword',
              'passwordLength': 8,
              'uppercase': true,
              'lowercase': true,
              'numbers':   true,
              'specialChars': false,
              /*'onPasswordGenerated': function(generatedPassword) {
              	alert('My new generated password is ' + generatedPassword);
              }  */
          });
      
	        $('.passgenlnkweb').pGenerator({
                  'bind': 'click',
                  'passwordElement': '#WebhostingApassword',
                  'displayElement': '#WebhostingApassword',
                  'passwordLength': 8,
                  'uppercase': true,
                  'lowercase': true,
                  'numbers':   true,
                  'specialChars': false,
                  /*'onPasswordGenerated': function(generatedPassword) {
                  	alert('My new generated password is ' + generatedPassword);
                  }  */
              });
	});
    </script>
</head>
<body>
<!-- app/View/Users/add.ctp -->
    <div class="mainwrapper">
        <div class="header">
            <div class="logo">
                <?php echo $this->Html->image('footer_logo.png');?>
            </div>
            <div class="rh_lnk">
                <a href="http://radioheart.ru" target="_blank">Radioheart.ru</a> (ссылка откроется в новом окне)
            </div>
        </div>
        <div class="steps" style='background: #6c6c6c;'>
            <div class="first_step_margin"></div>
            <div class="step arrow_box">Шаг 1. Регистрация</div>
            <div class="step arrow_box">Шаг 2. Заказ</div>
            <div class="step arrow_box">Шаг 3. Оплата</div>
            <div class="step arrow_box">Завершение</div>
        </div>
        <div class="content_wrapper">
	   <?php echo $this->Form->create('Order',array('action' => 'setup')); ?>
            <div class="step4title">Отлично! Заказ оплачен.</div>
            <div class="step4maintext">
              Осталось заполнить несколько полей для настройки вашего заказа. <br />
              Вы всегда сможете изменить эти данные. 
            </div>
            <div class="step4wrp">
              <table cellspacing="10">
		<?php
		if($radiohost==1)
		{
			echo $this->Form->input('id', array(
			'value' => $radiohost_order_id,
			'label' => false,
			'type' =>'hidden',
			'style' => 'display:none'
			));
			echo $this->Form->input('radiohost', array(
			'value' => 1,
			'label' => false,
			'type' =>'hidden',
			'style' => 'display:none'
			));
			echo $this->Form->input('oplachenodo', array(
			'value' => $oplachenodo,
			'label' => false,
			'type' =>'hidden',
			'style' => 'display:none'
			));
			
			?>
			<tr valign="middle">
			  <td colspan="3">
			    <span class="step4itemtitle">Радиохостинг. ID заказа <?php echo $radiohost_order_id;?></span>
			  </td>
			</tr>
			<tr valign="middle">
			  <td width="160">Маунт <span class="required_field">*</span></td>
			  <td width="240">
				<?php
				echo $this->Form->input('mount', array(
					'label' => false,
					'value' => '/live',
					'class'=>'step4input',
					'id'=>'mount',
					'required'=>1
					));
				?>
				<!--<input name="mount" class="step4input" id="mount"/>-->
			  </td>
			  <td><a href="http://radioheart.ru/2-6-chto-takoe-maunt/" target="_blank">Для чего нужен маунт?</a> <span class="reg_tooltip">(ссылка откроется в новом окне)</span></td>
			</tr>
			<tr valign="middle">
			  <td width="160">Пароль <span class="required_field">*</span></td>
			  <td width="240">
				<?php
				echo $this->Form->input('apassword', array(
					'label' => false,
					'class'=>'step4input',
					'id'=>'OrderApassword',
					'required'=>1
					));
				?>
			  </td>
			  <td>
				Пароль используется для эфира, FTP и автодиджея
				<br />
				<?php echo $this->Html->link('Сгенерировать', '#', array('class' => 'passgenlnk'));?>
			  </td>
			</tr>
			<tr valign="middle">
			  <td width="160">Название станции <span class="required_field">*</span></td>
			  <td width="240">
				<?php
				echo $this->Form->input('stationname', array(
					'label' => false,
					'class'=>'step4input',
					'id'=>'stationname',
					'required'=>1
					));
				?>
			  </td>
			  <td></td>
			</tr>
			<tr valign="middle">
			  <td width="160">Ссылка сайт станции</td>
			  <td width="240">
				<?php
				echo $this->Form->input('stationsite', array(
					'label' => false,
					'class'=>'step4input',
					'id'=>'stationsite',
					));
				?>
			  </td>
			  <td></td>
			</tr>
			<tr valign="middle">
			  <td colspan="3">
			    <div class="rh_plans_line">
			      <?php echo $this->Html->image('newsline.png',array('class'=>'newsline'));?>
			      <br /><br />
			    </div>
			  </td>
			</tr>
		<?php
		} //END IF radiohost
		if($webhost==1)
		{
			echo $this->Form->input('id_web', array(
			'value' => $webhost_order_id,
			'label' => false,
			'type' =>'hidden',
			'style' => 'display:none'
			));
			echo $this->Form->input('webhost', array(
			'value' => 1,
			'label' => false,
			'type' =>'hidden',
			'style' => 'display:none'
			));
			echo $this->Form->input('webhost_oplachenodo', array(
			'value' => $webhost_oplachenodo,
			'label' => false,
			'type' =>'hidden',
			'style' => 'display:none'
			));
		?>
			<tr valign="middle">
			  <td colspan="3">
			    <span class="step4itemtitle">Виртуальный хостинг. ID заказа <?php echo $webhost_order_id;?></span>
			  </td>
			</tr>
			<tr valign="middle">
			  <td width="160">Пароль <span class="required_field">*</span></td>
			  <td width="240">
				<?php
				echo $this->Form->input('password_web', array(
					'label' => false,
					'class'=>'step4input',
					'id'=>'WebhostingApassword',
					'required'=>1
					));
				?>
			  </td>
			  <td>
				Пароль используется для панели управления
				<br />
				<?php echo $this->Html->link('Сгенерировать', '#', array('class' => 'passgenlnkweb'));?>
			  </td>
			</tr>
			<tr valign="middle">
			  <td colspan="3">
			    <div class="rh_plans_line">
			      <?php echo $this->Html->image('newsline.png',array('class'=>'newsline'));?>
			    </div>
			  </td>
			</tr>
		<?php
		}//END IF webhost
		?>
              </table>
            </div>           
            <div class="paymyorder">
              <!--<a href="javascript:{}" onclick="document.getElementById('order_submit').submit(); return false;">Отправить данные</a>-->
	      <?php echo $this->Form->end(__('Отправить данные'));?>
            </div>
          <div class="skip_steps">
          </div>
        </div>
    </div>
    <div class="footer_wrapper">
        <div class="footer">
            <div class="footer_copies">©  2013  Компания «Radioheart.ru»</div>
            <div class="rh_lnk_footer">
                <a href="http://radioheart.ru" target="_blank">Radioheart.ru</a> (ссылка откроется в новом окне)
            </div>
        </div>
    </div>
</body>
</html>